/* 
 * Copyright 2011 VelocitiSoftware
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.velociti.ikarus.ui.widget;

import java.util.ArrayList;

import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.ui.ClientWidget;
import com.vaadin.ui.CssLayout;
import com.velociti.ikarus.widget.client.ui.VIkarusDock;
/**
 * ######IkarusDockLayout##### 
 * -Simplified and modified version of http://www.wizzud.com/jqDock/
 * -Check http://www.wizzud.com/jqDock/ site for the usage.
 * -Needs JQuery js.
 * 
 * @author Alper Turkyilmaz - VelocitiSoftware - 2011
 * @version 1.0.2
 * 
 */
@ClientWidget(VIkarusDock.class)
class IkarusDockLayout extends CssLayout {

	public interface alignment {
		String horizontal_top = "top";
		String horizontal_middle = "middle";
		String horizontal_bottom = "bottom";
		String vertical_left = "left";
		String vertical_center = "center";
		String vertical_right = "right";
	}

	public interface labelposition {
		String topleft = "tl";
		String topcenter = "tc";
		String topright = "tr";
		String middleleft = "ml";
		String middlecenter = "mc";
		String middleright = "mr";
		String bottomleft = "bl";
		String bottomcenter = "bc";
		String bottomright = "br";
	}

	public interface loader {
		String image = "image";
		String jquery = "jquery";
	}

	private ArrayList<String> styleNames;

	private int active = -1;
	private String align = alignment.horizontal_bottom;
	private int bias = 50;
	private double coefficient = 1.5;
	private int distance = 72;
	private int duration = 300;
	private int fadeIn = 0;
	private String fadeLayer = "";
	private boolean flow = false;
	private int idle = 0;
	private int inactivity = 0;
	private String labelPosition = labelposition.topleft;
	private boolean useLabel = false;
	private boolean noBuffer = false;
	private int size = 48;
	private int step = 50;
	private String loader = "";

	// TODO to be supported !!
	// onReady : function, default = [none]
	// onSleep : function, default = [none]
	// onWake : function, default = [none]
	// setLabel : function, default = [none]
	// source : function, default = [none]
	// src : string or function

	public IkarusDockLayout() {

	}

	public void paintContent(PaintTarget target) throws PaintException {
		super.paintContent(target);

		target.addAttribute("stylenames", getStyleName());
		target.addAttribute("active", active);
		target.addAttribute("align", align);
		target.addAttribute("bias", bias);
		target.addAttribute("coefficient", coefficient);
		target.addAttribute("distance", distance);
		target.addAttribute("duration", duration);
		target.addAttribute("fadeIn", fadeIn);
		target.addAttribute("fadeLayer", fadeLayer);
		target.addAttribute("flow", flow);
		target.addAttribute("idle", idle);
		target.addAttribute("inactivity", inactivity);
		if (useLabel) {
			target.addAttribute("uselabels", useLabel);
			target.addAttribute("labels", labelPosition);
		}
		target.addAttribute("noBuffer", noBuffer);
		target.addAttribute("size", size);
		target.addAttribute("step", step);
		target.addAttribute("loader", loader);
	}

	public boolean isUseLabel() {
		return useLabel;
	}

	public void setUseLabel(boolean useLabel) {
		this.useLabel = useLabel;
		requestRepaint();
	}

	public int getActive() {
		return active;
	}

	public void setActive(int active) {
		this.active = active;
		requestRepaint();
	}

	public String getAlign() {
		return align;
	}

	public void setAlign(String align) {
		this.align = align;
		requestRepaint();
	}

	public int getBias() {
		return bias;
	}

	public void setBias(int bias) {
		this.bias = bias;
		requestRepaint();
	}

	public double getCoefficient() {
		return coefficient;
	}

	public void setCoefficient(double coefficient) {
		this.coefficient = coefficient;
		requestRepaint();
	}

	public int getDistance() {
		return distance;
	}

	public void setDistance(int distance) {
		this.distance = distance;
		requestRepaint();
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
		requestRepaint();
	}

	public int getFadeIn() {
		return fadeIn;
	}

	public void setFadeIn(int fadeIn) {
		this.fadeIn = fadeIn;
		requestRepaint();
	}

	public String getFadeLayer() {
		return fadeLayer;
	}

	public void setFadeLayer(String fadeLayer) {
		this.fadeLayer = fadeLayer;
		requestRepaint();
	}

	public boolean isFlow() {
		return flow;
	}

	public void setFlow(boolean flow) {
		this.flow = flow;
		requestRepaint();
	}

	public int getIdle() {
		return idle;
	}

	public void setIdle(int idle) {
		this.idle = idle;
		requestRepaint();
	}

	public int getInactivity() {
		return inactivity;
	}

	public void setInactivity(int inactivity) {
		this.inactivity = inactivity;
		requestRepaint();
	}

	public String getLabelPosition() {
		return labelPosition;
	}

	public void setLabelPosition(String labelPosition) {
		this.labelPosition = labelPosition;
		requestRepaint();
	}

	public boolean isNoBuffer() {
		return noBuffer;
	}

	public void setNoBuffer(boolean noBuffer) {
		this.noBuffer = noBuffer;
		requestRepaint();
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
		requestRepaint();
	}

	public int getStep() {
		return step;
	}

	public void setStep(int step) {
		this.step = step;
		requestRepaint();
	}

	public String getLoader() {
		return loader;
	}

	public void setLoader(String loader) {
		this.loader = loader;
		requestRepaint();
	}
}
